<template>
	<view class="noticeWarps">
		<view class="notice_item"
			v-for="(item,index) in noticeList" :key="index"
			@click="$navTo(`./notcieDetail?id=${item.id}`)"
		>
			<view class="overfont title bold">{{item.title}}</view>
			<view class="">{{item.createTime}}</view>
		</view>
		<!-- 加载 -->
		<loadMore :isLoading="isLoading" :isDone="isDoneTask" />
	</view>
</template>

<script>
	import loadMore from '@/components/loadMore/loadMore'
	export default {
		data() {
			return {
				isLoading:false,
				isDoneTask:false,
				page:{
					pageIndex:1,
					limit:10,
					totalPage:0
				},
				noticeList:[],
			};
		},
		components:{
			loadMore
		},
		onShow() {
			this.getNotceList();
		},
		methods:{
			//查询我的任务
			async getNotceList(){
				const _this = this;
				_this.isLoading = true;
				_this.isDoneTask = false;
				let res = (await _this.$http('/api/unAuth/communique/listCommunique','POST',{
					page:_this.page.pageIndex,
					limit:_this.page.limit
				})).data;
				uni.stopPullDownRefresh();
				_this.isLoading = false;
				if(res && res.code == '0'){
					let list = res.data.list;
					_this.page.totalPage = res.data.totalPage;
					if(_this.page.pageIndex <= 1){
						_this.noticeList.splice(0);
					}
					if(_this.page.totalPage <= _this.page.pageIndex){
						_this.isDoneTask = true;
					}else{
						_this.isDoneTask = false;
					}
					_this.noticeList = _this.noticeList.concat(list);
				}else{
					_this.$showToast(res.msg);
				}
			},
		},
		onPullDownRefresh() {
			this.page.pageIndex = 1;
			this.getNotceList();
		}
		,//滚动到底部
		onReachBottom() {
			const _this =this;
			if(_this.page.pageIndex < _this.page.totalPage){
				_this.page.pageIndex++;
				_this.getNotceList();
			}else{
				_this.isDoneTask = true;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.noticeWarps{
		box-sizing: border-box;
		width: 100%;
		min-height: 100vh;
		padding: 24rpx;
		border-top: solid 2rpx #F6F6F6;
		background-color: #F8F8F8;
		.notice_item{
			background-color: #fff;
			border-radius: 12rpx;
			border-left: $ych_color solid 10rpx;
			padding: 32rpx;
			margin-bottom: 24rpx;
			.title{
				color: #1A1A1A;
				font-size: 32rpx;
				margin-bottom: 20rpx;
			};
		}
	}
</style>
